public class Sort {
    //插入排序
    public static void inSort(int[] array) {
        int tem = 0;
        for (int i = 1; i < array.length; i++) {
            tem = array[i];
            int j = 0;
            for (j = i-1; j >= 0; j--) {
                if(array[j] > tem) {
                    array[j+1] = array[j];
                }else {
                    //array[j+1] = tem;
                    break;
                }
            }
            array[j+1] = tem;
        }
    }


    //希尔排序
    public static void shellSort(int[] array) {
        int gap = array.length;
        while(gap > 1) {
            gap /= 2;
            shell(array,gap);
        }
    }

    public static void shell(int[] array,int gap) {
        int tem = 0;
        for (int i = gap; i < array.length; i++) {
            tem = array[i];
            int j = 0;
            for (j = i-gap; j >= 0; j -= gap) {
                if(array[j] > tem) {
                    array[j+gap] = array[j];
                }else {
                    //array[j+1] = tem;
                    break;
                }
            }
            array[j+gap] = tem;
        }
    }
}
